package cn.cnlee.app.repository;

import cn.cnlee.app.remote.ApiService;
import cn.cnlee.arch.base.AbsRepository;
import cn.cnlee.arch.event.LiveBus;
import cn.cnlee.arch.http.RemoteClient;

/**
 * Repository基类（创建通用的接口服务以及提供LiveBus事件发送功能）
 */
public class BaseRepository extends AbsRepository {

    protected ApiService apiService;

    public BaseRepository() {
        apiService = RemoteClient.getInstance().create(ApiService.class);
    }

    protected void postData(Object eventKey, Object t) {
        postData(eventKey, null, t);
    }

    protected void postData(Object eventKey, String tag, Object t) {
        LiveBus.get().postEvent(eventKey, tag, t);
    }

    protected void showPageState(Object eventKey, String state) {
        postData(eventKey, state);
    }

    protected void showPageState(Object eventKey, String tag, String state) {
        postData(eventKey, tag, state);
    }
}
